1: Always try to choose easily readable identifiers names. eg. : Identifier to indicate girl height and boy height, we can use GirlHeight and BoyHeight.
Example:
classDatabasehandler { int girlHeight, boyHeight; // don't use word like g, h or GlHgt etc. which is not able to understand. }
2. Always use brevity words.
Brevity means concise and exact use of words in writing or speech.
Example:
classDatabasehandler { int girlHeight, boyHeight; // don't use phrases like elevation_above_ground }
3. Avoid use of underscores, hyphens or any other non-alphanumeric characters.
Like don't use Girl_Height, Girl1 etc.
Example:
classDatabasehandler { int girlHeight, boyHeight; // Don't use variable name like girl1 boy2 etc. }
4. Avoid use of Hungarian Notation. It creates contradiction as well as ambiguity to
the developer.
What is Hungarian notation?
Notation which start like intA or charC , stringZ etc. are called Hungarian Notation.
There are some language where there is no datatype for example Basic Combined Programming Language (BCPL) so there is necessary to use this notation.
Example:
classDatabasehandler { int girlHeight, boyHeight; // Don't use variable name like intGirl flootBoy2 etc. }
5. Do not use identifiers that conflict with keywords of widely used programming
language.
Don’t use name as class, exception, string etc.
Example:
classDatabasehandler { string errMessage; // Don't use variable name like exception etc. }
6. Do not use abbreviation or contradiction as part of identifiers names.
Example:
classDatabasehandler { int girlHeight, boyHeight; // Don't use variable name like girlchar, boyname. }
7. Class name should be a noun and meaningful, avoid the use of verbs. Don't prefix (“C”) in class name. Always use 1st word as a capital letter.
Example:
classDatabasehandler // Don't use word like CdatabaseHandler. Don’t use handling instead of handling. { int girlHeight, boyHeight; }
8. Namespace: names should be meaningful and complete. Always use 1st word
9: Methods: Always use a verb-noun pair. Avoid use of camel casing.
Camel Casing means that the word which starts with small letter and then capital letter eg: iPhone. there is no use of spaces or hyphen in this format
Example:
namespace SchoolProject { classDatabasehandler { publicvoid EntryDetails()// Don’t use the word like eDetails etc. { // } } };
10. Private Member Variables: if we are declaring private member variable then we should add prefix or suffix to all class level member variables with (underscore)
eg:. m_ or _m.
Example:
classdatabasehandler { privateint entry_; }
11. Interfaces: It should have prefix 'I' interface.
Example: namespace SchoolProject { interfaceIdatabaseHandler { int newEntry; }
12. Custom Exception: We should use ‘Exception’ keyword at the end of the naming of custom Exception.
Abhishek Srivasatava
27-Sep-2016Naming Convention :
1: Always try to choose easily readable identifiers names. eg. : Identifier to indicate girl height and boy height, we can use GirlHeight and BoyHeight.
Example:
2. Always use brevity words.
Brevity means concise and exact use of words in writing or speech.
Example:
3. Avoid use of underscores, hyphens or any other non-alphanumeric characters.
Like don't use Girl_Height, Girl1 etc.
Example:
4. Avoid use of Hungarian Notation. It creates contradiction as well as ambiguity to
the developer.
What is Hungarian notation?
Notation which start like intA or charC , stringZ etc. are called Hungarian Notation.
There are some language where there is no datatype for example Basic Combined Programming Language (BCPL) so there is necessary to use this notation.
Example:
language.
Don’t use name as class, exception, string etc.
Example:
6. Do not use abbreviation or contradiction as part of identifiers names.
Example:
7. Class name should be a noun and meaningful, avoid the use of verbs. Don't prefix (“C”) in class name. Always use 1st word as a capital letter.
Example:
8. Namespace: names should be meaningful and complete. Always use 1st word
as capital letter
9: Methods: Always use a verb-noun pair. Avoid use of camel casing.
Camel Casing means that the word which starts with small letter and then capital letter eg: iPhone. there is no use of spaces or hyphen in this format
Example:
10. Private Member Variables: if we are declaring private member variable then we should add prefix or suffix to all class level member variables with (underscore)
eg:. m_ or _m.
Example:
11. Interfaces: It should have prefix 'I' interface.
Example: